#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>

void transpose(int arr[10][10],int x,int y)
{
	int i = 0;
	int j = 0;
	for (i = 0; i < y; i++)
	{
		for (j = 0; j < x; j++)
			printf("%d ", arr[j][i]);
		printf("\n");
	}

}

int main()
{
	int arr[10][10] = { 0 };
	int N = 0;
	int M = 0;
	scanf("%d %d", &N, &M);
	int i = 0;
	int j = 0;
	for (i = 0; i < N; i++)
		for (j = 0; j < M; j++)
			scanf("%d", &arr[i][j]);
	transpose(arr, N, M);
	return 0;
}